from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time

driver = webdriver.Chrome(executable_path=r"D:\python\chromedriver.exe")
driver.get("http://121.43.169.97:8848/pageA.html")

try:
    # 定位用户名输入框
    username = driver.find_element(By.NAME, "userA")
    # 输入用户名：admin1，暂停2秒
    username.send_keys("admin1")
    time.sleep(2)
    # 删除1
    username.send_keys(Keys.BACK_SPACE)
    time.sleep(2)
    # 全选用户名：admin，暂停2秒
    username.send_keys(Keys.CONTROL, 'a')
    time.sleep(2)
    # 复制用户名：admin，暂停2秒
    username.send_keys(Keys.CONTROL, 'c')
    time.sleep(2)
    # 粘贴到密码框（假设密码框id为passwordA，需根据实际页面调整）
    password = driver.find_element(By.ID, "passwordA")
    password.send_keys(Keys.CONTROL, 'v')
finally:
    time.sleep(2)
    driver.quit()